package l1j.opqlo.NewSystem;

import static l1j.server.server.model.skill.L1SkillId.ABSOLUTE_BARRIER;
import static l1j.server.server.model.skill.L1SkillId.EARTH_BIND;
import static l1j.server.server.model.skill.L1SkillId.FREEZING_BLIZZARD;
import static l1j.server.server.model.skill.L1SkillId.FREEZING_BREATH;
import static l1j.server.server.model.skill.L1SkillId.ICE_LANCE;
import static l1j.server.server.model.skill.L1SkillId.NPC_FREEZING_BREATH;
import static l1j.server.server.model.skill.L1SkillId.SHOCK_STUN;
import static l1j.server.server.model.skill.L1SkillId.STATUS_FREEZE;
import static l1j.server.server.model.skill.L1SkillId.STATUS_CURSE_PARALYZING;
import static l1j.server.server.model.skill.L1SkillId.STATUS_CURSE_PARALYZED;
import static l1j.server.server.model.skill.L1SkillId.CURSE_PARALYZE;
import static l1j.server.server.model.skill.L1SkillId.CURSE_PARALYZE2;
import l1j.server.server.model.L1Character;
import l1j.server.server.model.Instance.L1PcInstance;

public class L1AttackCancel {

	private static int[] _skillList = { ABSOLUTE_BARRIER, ICE_LANCE,
			FREEZING_BLIZZARD, FREEZING_BREATH, EARTH_BIND, NPC_FREEZING_BREATH };
	private static int[] _clearskill = { ABSOLUTE_BARRIER, ICE_LANCE,
			FREEZING_BLIZZARD, FREEZING_BREATH, EARTH_BIND,
			NPC_FREEZING_BREATH, SHOCK_STUN, STATUS_FREEZE,
			STATUS_CURSE_PARALYZING, STATUS_CURSE_PARALYZED, CURSE_PARALYZE,
			CURSE_PARALYZE2 };
	private static int[] _teleportskill = {ICE_LANCE,FREEZING_BLIZZARD,FREEZING_BREATH,
		EARTH_BIND,NPC_FREEZING_BREATH, SHOCK_STUN, STATUS_FREEZE,STATUS_CURSE_PARALYZING, 
		STATUS_CURSE_PARALYZED, CURSE_PARALYZE,CURSE_PARALYZE2 };
	
	/**是否有無法順移的狀態**/
	public static boolean haveCantTeleport(final L1PcInstance pc){
		if(pc == null){
			return true;
		}
		for(final int skill : _teleportskill){
			if(pc.hasSkillEffect(skill)){
				return true;
			}
		}
		return false;
	}
	
	/** 是否擁有冰凍狀態 (是=TRUE 否=FALSE) */
	public static boolean haveCancelSkill(final L1Character cha) {
		if (cha == null) {
		return false;
	  }
		if(cha instanceof L1PcInstance){
			final L1PcInstance pc = (L1PcInstance)cha;
			if(pc.isTeleport()){
				return false;
			}
		}
		for (final int skill : _skillList) {
			if (cha.hasSkillEffect(skill)) {
				return true;
			}
		}
		return false;
	}

	/** 消除所有控場技 */
	public static void removeSkill(final L1Character cha) {
		for (final int skill : _clearskill) {
			if (cha.hasSkillEffect(skill)) {
				cha.removeSkillEffect(skill);
			}
		}
	}
}
